package zaphod;

public class Driver {
	public static void main(String[] args) {
		String input = "SIGSEGV";
		char[] charArray = input.toCharArray();
		int i, j;

		String str = "";

		Polynomial result = new Polynomial(0, 0);
		for (i = 0; i < charArray.length; i++) {
			Polynomial term = new Polynomial(0, 1);
			for (j = 0; j < charArray.length; j++) {
				if (i != j) {
					term = term.multiply(new Polynomial(1, 1)
							.minus(new Polynomial(0, j)));
				}
			} // eo for j

			str = str + "+" + "(" + term.multiply(charArray[i]).toString()
					+ ")/" + term.evaluate(i);
			term = term.multiply(charArray[i] / term.evaluate(i));
			// System.out.println(term + "=" + term.evaluate(i));
			result = result.plus(term);
		} // eo for i

		System.out.print("!ruby " + input.length()
				+ ".times { |x| (");
		System.out.print(result);
		System.out.println(").round.chr.display }");
	} // eo main
}
